﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ImageUploader.domain;

namespace ImageUploader.GUI
{
    public partial class OverwriteUserDialog : Form
    {
        public OverwriteUserDialog(string cn)
        {
            InitializeComponent();
            this.lblMessage.Text = "The user " + cn + " already exists in the Active Directory, do you want to overwrite it?";
            this.StartPosition = FormStartPosition.CenterScreen;
          //  foreach(Button b in this.Controls.OfType<Button>())
          //      b.TabStopChanged += new EventHandler(b_TabStopChanged);
        }

        /*private void b_TabStopChanged(object sender, EventArgs e)
        {
            this.AcceptButton = (Button)sender;
        }*/

        private void btnOverwrite_Click(object sender, EventArgs e)
        {
            OverwriteAnswer = new OverwriteAnswer(chkBoxSave.Checked, domain.OverwriteAnswer.OverWriteResult.Overwrite);
            CloseDialog();
        }

        private void btnSkipUser_Click(object sender, EventArgs e)
        {
            OverwriteAnswer = new OverwriteAnswer(chkBoxSave.Checked, domain.OverwriteAnswer.OverWriteResult.Skip);
            CloseDialog();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            OverwriteAnswer = new OverwriteAnswer(chkBoxSave.Checked, domain.OverwriteAnswer.OverWriteResult.Cancel);
            CloseDialog();
        }

        private void CloseDialog()
        {
            DialogResult = DialogResult.None;
            this.Close();
        }

        public OverwriteAnswer OverwriteAnswer
        {
            get;
            private set;
        }

    }
}
